home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / addtail.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  82 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addtail.c,v 1.5 1996/08/13 13:55:56 digulla Exp $
  4.     $Log: addtail.c,v $
  5.     Revision 1.5  1996/08/13 13:55:56  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.4  1996/08/01 17:41:03  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17.  
  18. /*****************************************************************************
  19.  
  20.     NAME */
  21.     #include <exec/lists.h>
  22.     #include <clib/exec_protos.h>
  23.  
  24.     __AROS_LH2I(void, AddTail,
  25.  
  26. /*  SYNOPSIS */
  27.     __AROS_LHA(struct List *, list, A0),
  28.     __AROS_LHA(struct Node *, node, A1),
  29.  
  30. /*  LOCATION */
  31.     struct SysBase *, SysBase, 41, Exec)
  32.  
  33. /*  FUNCTION
  34.     Insert Node node at the end of a list.
  35.  
  36.     INPUTS
  37.     list - The list to insert the node into
  38.     node - This node is to be inserted
  39.  
  40.     RESULT
  41.  
  42.     NOTES
  43.  
  44.     EXAMPLE
  45.     struct List * list;
  46.     struct Node * pred;
  47.  
  48.     // Insert Node at end of the list
  49.     AddTail (list, node);
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.     26-08-95    digulla created after EXEC-Routine
  59.     26-10-95    digulla adjusted to new calling scheme
  60.  
  61. ******************************************************************************/
  62. {
  63.     __AROS_FUNC_INIT
  64.     assert (node);
  65.     assert (list);
  66.  
  67.     /*
  68.     Make the node point to the head of the list. Our predecessor is the
  69.     previous last node of the list.
  70.     */
  71.     node->ln_Succ           = (struct Node *)&list->lh_Tail;
  72.     node->ln_Pred           = list->lh_TailPred;
  73.  
  74.     /*
  75.     Now we are the last now. Make the old last node point to us
  76.     and the pointer to the last node, too.
  77.     */
  78.     list->lh_TailPred->ln_Succ = node;
  79.     list->lh_TailPred           = node;
  80.     __AROS_FUNC_EXIT
  81. } /* AddTail */
  82.